package cn.xw.controller;

import org.omg.CORBA.OBJ_ADAPTER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

@RestController
public class ClientController {

    @Autowired
    RestTemplate restTemplate;

    @RequestMapping("/get")
    public Map<String, Object> get(){
        Map<String,Object> map=new HashMap<>();
        Map<String,Object> map1=restTemplate.getForObject("http://member-service/getUserInfo",Map.class);
        Map<String ,Object> map2=restTemplate.getForObject("http://order-service/getOrder",Map.class);
        for(Map.Entry<String, Object> entry : map1.entrySet()){
            String mapKey = entry.getKey();
            Object mapValue = entry.getValue();
            System.out.println(mapKey+":"+mapValue);
            map.put(mapKey,mapValue);
        }
        for(Map.Entry<String, Object> entry : map2.entrySet()){
            String mapKey = entry.getKey();
            Object mapValue = entry.getValue();
            System.out.println(mapKey+":"+mapValue);
            map.put(mapKey,mapValue);
        }
        return map;
    }

}
